
import sys, os
import pygame, random
from pygext.gl.all import *

def random_position():
    return random.randint(0,800)-400, random.randint(0,600)-300, 0
    
class ImageScene(Scene):

    def enter(self):
        # Create three layers to control drawing order.
        # Since depth isn't explicitly defined, the layer that is
        # defined first will the drawn first (i.e. it will end up
        # behind the other layers)
        self.new_layer("layer1")
        self.clock = pygame.time.Clock()

        # Alternative way is to create the Bitmap object manually.
        # The difference compared to the above is that the image
        # isn't cached for possible later use.
        bmp = Bitmap("fashion_boy/data/alien.gif")
        
        self.all = all = []
        for x in range(100):
            e = Entity(bmp)
            all.append( e )
            e.place("layer1")
        
    def tick(self):
        self.clock.tick(200)
        for e in self.all:
            x, y, z = random_position()
            e.x = x+400
            e.y = y+300
            e.scale = 2
    def handle_keydown(self, k): 
        print "FPS:", self.clock.get_fps()
        raise "foo"

screen.init((800,600))
director.run(ImageScene)
        
